<script language="javascript" type="text/javascript" src="../../js/ajax.js"></script>
<script type="text/javascript" src="../layout/js/funciones.js"></script>

<?php
require_once '../../controllers/seguridad.php';
require_once("../layout/head.php");
include_once '../../class/classFormulario.php';
include_once '../../class/classUtils.php';
include_once '../../class/classUsuario.php';
include_once '../../class/classUbicacion.php';

$utils = new Utils();
$formulario = new Formulario();
$Ousuario = new Usuario();
$oUbicacion = new Ubicacion();


$lstRegion = $oUbicacion->getRegiones();

if ($_GET['id'] > 0) {
    $user = $Ousuario->loadById($_GET['id']);
}
?>

<div id="generalcontent2">
    <div class="title">Usuarios</div>
    <div id="contenidos">
        <?php
        if (isset($_REQUEST['e']) && $_REQUEST['e'] != "") {
            $utils->mensaje($_REQUEST['e'], $_REQUEST['t']);
        }
        ?>	
        <div class="alerta">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspDebe completar todos los datos solicitados</div>
        <br></br>
        <form action="../../controllers/usuarios.php"  method="post" name="formulario"/>

        <table id="tabFomNewUser" border="0">
            <tr>
                <td>
                    <label>RUT </label><br>
                    <?php echo $formulario->input("USU_RUT", $user->USU_RUT, "11", "11", "", "USU_RUT") . " - " . $formulario->input("USU_DV", $user->USU_DV, "1", "1", "", "USU_DV"); ?>
                </td>
                <td>
                    <label>Nombre </label><br>
                    <?php echo $formulario->input("USU_NOMBRES", $user->USU_NOMBRES, "20", "20", "", "USU_NOMBRES"); ?>
                </td>
                <td>
                    <label>Apellido Paterno </label><br>
                    <?php echo $formulario->input("USU_AP_PATERNO", $user->USU_AP_PATERNO, "20", "20", "", "USU_AP_PATERNO"); ?>
                </td>
                <td>
                    <label>Apellido Materno </label><br>
                    <?php echo $formulario->input("USU_AP_MATERNO", $user->USU_AP_MATERNO, "20", "20", "", "USU_AP_MATERNO"); ?>
                </td>
            </tr>
            <tr>
                <td>
                    <label>Regi&oacute;n </label><br>
                    <?php
                    echo $formulario->combobox($lstRegion, "REG_ID", $lstRegion[$user->USU_ID], "Seleccione", "onChange=\"cargaProvincias(this.value)\";style=\"width:200px\";");
                    ?>                    
                </td>
                <td>
                    <label>Provincia </label><br>
                    <div id="div_provincia">                    
                        <select name= "PROV_ID" disabled="disabled">
                            <option value="0">seleccione</option>
                        </select>
                    </div>
                </td>    
                <td>
                    <label>Comuna </label><br>
                    <div id="div_comuna">
                        <select name= "COM_ID" disabled="disabled">
                            <option value="0">seleccione</option>
                        </select>
                    </div>   
                </td>
                <td>
                    <label>Direcci&oacute;n </label><br>
                    <?php echo $formulario->input("USU_AP_PATERNO", $user->USU_DIRECCION, "20", "20", "", "USU_AP_PATERNO"); ?>
                </td>
            </tr> 
            <tr>
                <td>
                    <label>Tel&eacute;fono </label><br>
                    <?php echo $formulario->input("USU_FONO", $user->USU_TELEFONO, "20", "20", "", "USU_FONO"); ?>
                </td>
                <td>
                    <label>Email </label><br>
                    <?php echo $formulario->input("USU_EMAIL", $user->USU_EMAIL, "20", "20", "", "USU_EMAIL"); ?> 
                </td>
                <td>
                    <label>Nombre de usuario: </label><br>
                    <?php echo $formulario->input("USU_USUARIO", $user->USU_USUARIO, "20", "20", "", "USU_USUARIO"); ?>
                </td>

            </tr>
            <tr>
                <td colspan="4">
                    <input id="action" name="action" type="hidden" value="grabar" />
                    <input id="id" name="id" type="hidden" value="<?php echo $_REQUEST['id']; ?>" />
                    <input id="clavemd5" name="clavemd5" type="hidden" value="clavemd5" />
                    <input id="r" name="r" type="hidden" value="<?php echo $_REQUEST['r']; ?>" />
                    <input name="Guardar" type="button" onclick="enviar_usuario()" value="Guardar" class="boton" />
                </td>

            </tr>
        </table>
        <br>

        </form>
        <?php
        require_once '../layout/pie.php';
        ?>